import request from './request';

// 创建动态API加载函数
const createAPI = (endpoint: string, method: string, data?: any) => {
    return {
        url: endpoint,
        method,
        data: method.toLowerCase() === 'post' ? data : null,
        params: method.toLowerCase() === 'get' ? data : null
    };
};

// API函数
const api = {
    // 登录接口
    login: (data: { phone: string; password: string }) =>
        request(createAPI('home/PostLogin', 'post', data)),

    // 获取设备列表
    getDevices: (params: any) =>
        request(createAPI('device/getList', 'get', params)),

    // 更多API...
};

export default api;